Main components of an R-package
A cartoon of an R package
A cartoon of an R package
Easy to use
Easy to get help
A lot of work has been done already
Easy to use
Easy to get help
A lot of work has been done already
A set of functions or data!
## Loading required package: sp
## class : RasterLayer
## dimensions : 180, 360, 64800 (nrow, ncol, ncell)
## resolution : 1, 1 (x, y)
## extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
More than XXX packges on CRAN!
vegan
lme, INLA
raster, sp
ape, phytools
Distribute code
Distribute data
Organize analyses
Collaborate on a project
1. The Comprehensive R Archive Network
2. GitHub
## # A tibble: 3,272 x 12
## tax_accepted_na~ tax_genus tax_tribus tax_subfamily geo_range
## <chr> <chr> <chr> <chr> <dbl>
## 1 Acanthostachys ~ Acanthos~ <NA> Bromelioideae 7695
## 2 Acanthostachys ~ Acanthos~ <NA> Bromelioideae 613125
## 3 Aechmea abbrevi~ Aechmea <NA> Bromelioideae 15625
## 4 Aechmea aculeat~ Aechmea <NA> Bromelioideae 11499
## 5 Aechmea aenigma~ Aechmea <NA> Bromelioideae 7436
## 6 Aechmea aguadoc~ Aechmea <NA> Bromelioideae 7701
## 7 Aechmea aiuruoc~ Aechmea <NA> Bromelioideae 7705
## 8 Aechmea alba Mez Aechmea <NA> Bromelioideae 89375
## 9 Aechmea alegren~ Aechmea <NA> Bromelioideae 7703
## 10 Aechmea alopecu~ Aechmea <NA> Bromelioideae 27649
## # ... with 3,262 more rows, and 7 more variables: conv_conr_eoo <dbl>,
## # conv_conr_aoo <dbl>, conv_conr_pop <dbl>, conv_conr_code <chr>,
## # conv_conr_stat <chr>, tr_growth_form <chr>, tax_canonical <chr>
## Simple feature collection with 3272 features and 1 field
## geometry type: GEOMETRY
## dimension: XY
## bbox: xmin: -112.8833 ymin: -44.00848 xmax: -34.63333 ymax: 36.38029
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## First 10 features:
## tax_accepted_name
## 1 Acanthostachys pitcairnioides (Mez) Rauh & Barthlott
## 2 Acanthostachys strobilacea (Schult. & Schult.f.) Klotsch
## 3 Aechmea abbreviata L.B.Sm.
## 4 Aechmea aculeatosepala (Rauh & Barthlott) Leme
## 5 Aechmea aenigmatica Lopez-Ferrari, Espejo, Ceja et A.Mendoza
## 6 Aechmea aguadocensis Leme & L.Kollmann
## 7 Aechmea aiuruocensis Leme
## 8 Aechmea alba Mez
## 9 Aechmea alegrensis W.Weber
## 10 Aechmea alopecurus Mez
## geometry
## 1 POLYGON ((-41.478 -12.1831,...
## 2 MULTIPOLYGON (((-54.38333 -...
## 3 MULTIPOLYGON (((-75.88333 -...
## 4 POLYGON ((-78.1828 -3.26, -...
## 5 POLYGON ((-96.4525 16.1917,...
## 6 POLYGON ((-40.4689 -18.5706...
## 7 POLYGON ((-44.1391 -22.0335...
## 8 MULTIPOLYGON (((-40.13333 -...
## 9 POLYGON ((-41 -20.7089, -41...
## 10 POLYGON ((-43.6783 -22.5497...
A folder…
…with standardized structure and names
DESCRIPTION
README.md
NAMSPACE
R/
man/
data/
inst/, vignettes/, tests/ .Rbuildignore, .gitignore, cran-comments.md, NEWS.md
A text file giving basic and standradized information on the package
A screenshot of a description file, go through it and explain what to add
A free describtion of the package for github
Version number
What does the package do
How to contribute
Citation
A Picture of a markdown readme
A picture of a readme on github
A file with the names of all functions that your package uses and provides.
A picture of an old namespace file
The datasets distributed with the package. Can be example data or the purpose of the package.
Can be any object that can be loaded into R.
Tables, shape files
The code (functions) provided via your package.
In packages code is distributed as functions.
Functions are objects just as variables.
## [1] 4
## [1] 4
## [1] 1001
## [1] ":-)"
## [1] ":-("
The documentation of your code. One file per function.
## starting httpd help server ... done
inst/ - non-text files (e.g. pdfs)
vignettes/ - Tutorials and documentation
test - automated tests of the code
.gitignore - files git should ignore
.Rbuildignore - files R CMD build should ignore
An R package is a set of standardized folders
Description - basic information
Readme - basic information
data/ - datasets of the package
R/ - the functions of the package
man/ - the documentation of the code
others - to facilitate the developement progress and provide additional information
Rstudio, Github, Git, devtools, roxygen2
Rstudio workflow. Next lecture!
Chose a dataset from your research that you want to provide as an R package, and one or two basic functions to use it.